home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / xlib.zip / XDATES.INT < prev    next >
Text File  |  1992-09-06  |  4KB  |  106 lines

  1. (*****************************************************************************)
  2. (*                                                                           *)
  3. (*        filename        : XDATES.PAS                                       *)
  4. (*        author          : Stefan Boether / Compuserve Id : 100023,275      *)
  5. (*                                                 FidoNet :  2:242/200      *)
  6. (*                                                 FidoNet :  2:243/91       *)
  7. (*                                  Internet: 100023.275@CompuServe.COM      *)
  8. (*                                        Maus-Net: Stefan Böther @ HRO      *)
  9. (*        system          : TURBO 6.01 / TPW 1.5 / DOS 3.3 / WIN 3.1         *)
  10. (*        changes         :                                                  *)
  11. (*        when    what                                                who    *)
  12. (*---------------------------------------------------------------------------*)
  13. (*        02.04.91 inital release                                     Stefc  *)
  14. (*        25.04.92 one unit for all date/time functions               Stefc  *)
  15. (*        19.05.92 new function valid_time                            Stefc  *)
  16. (*        01.09.92 renamed from DATES to XDATES                       Stefc  *)
  17. (*****************************************************************************)
  18. (*  Description :  Gernal date & time functions that I need                  *)
  19. (*****************************************************************************)
  20.  
  21. UNIT XDates;
  22.  
  23. {$IFDEF Windows }
  24.   {$D-,L-}
  25. {$ELSE }
  26.   {$O+,D-,L-}
  27. {$ENDIF}
  28.  
  29. INTERFACE
  30.  
  31.   USES {$IFDEF Windows }
  32.          WinDos;
  33.        {$ELSE}
  34.          Dos;
  35.        {$ENDIF}
  36.  
  37.   CONST  Sunday    = 0;
  38.          Monday    = 1;
  39.          Tuesday   = 2;
  40.          Wednesday = 3;
  41.          Thursday  = 4;
  42.          Friday    = 5;
  43.          Saturday  = 6;
  44.  
  45.   TYPE   Date = record    (* compatible type to Btrieve Record Manager *)
  46.            Day   : BYTE;
  47.            Month : BYTE;
  48.            Year  : WORD;
  49.          end;
  50.  
  51.          dtoc = ARRAY[1..SIZEOF(Date)] OF CHAR;
  52.  
  53.          Time = record       (* compatible type to Btrieve Record Manager *)
  54.            Sec100: BYTE;
  55.            Sec   : BYTE;
  56.            Min   : BYTE;
  57.            Hour  : BYTE;
  58.          end;
  59.          ttoc = ARRAY[1..SIZEOF(Time)] OF CHAR;
  60.  
  61.   FUNCTION  date_to_int( Datum  : Date  ) : LONGINT;
  62.     (* change a date-structure to julian *)
  63.  
  64.   PROCEDURE int_to_date( Julian : LONGINT; VAR Datum : DATE );
  65.     (* change a julian date back to a date-structure *)
  66.  
  67.   FUNCTION  day_of_week( Datum  : Date     ) : BYTE;
  68.     (* return the dayofweek for the given date.
  69.        Sunday=0 .. Saturday=1 *)
  70.  
  71.   FUNCTION  leap_year( Datum  : Date ) : BOOLEAN;
  72.     (* return true if the given date is a lear-year *)
  73.  
  74.   FUNCTION  week_of_year( Datum : Date ) : INTEGER;
  75.     (* return the number of the week within the year *)
  76.  
  77.   PROCEDURE set_date( D,M,Y : WORD; VAR Datum : Date );
  78.     (* move the single parameters to a date-structure *)
  79.  
  80.   PROCEDURE sysdate( VAR Datum : Date );
  81.     (* Return the day from the system *)
  82.  
  83.   PROCEDURE set_time( H,M,S : WORD; VAR Zeit : Time );
  84.     (* move the single parameters to a time-structure *)
  85.  
  86.   PROCEDURE systime( VAR Zeit :Time );
  87.     (* Return the actual systemtime *)
  88.  
  89.   PROCEDURE Unix_to_DateTime( Date : LongInt; Var Datum : Date; Var Zeit : Time );
  90.     (* Convert a LongInt in the Unix flavor to separate variables           *)
  91.     (* Original code submitted by Mick Howland of f660.n690.z3.fidonet.org  *)
  92.     (* Modified by Brian Stark of p8.f3.n289.z1.fidonet.org                 *)
  93.  
  94.   PROCEDURE px_to_date( PxDate : LONGINT; VAR Datum:Date );
  95.     (* Change a Paradox-Datefield to my date-structure *)
  96.  
  97.   FUNCTION  date_to_px( Datum:Date ) : LONGINT;
  98.     (* Change my date-structure to paradox dateformat *)
  99.  
  100.   FUNCTION  valid_date( Datum:Date ):BOOLEAN;
  101.     (* Check if the date is a valid one *)
  102.  
  103.   FUNCTION  valid_time( Zeit:Time ):BOOLEAN;
  104.     (* Check if the time is a valid one *)
  105.  
  106.